#include "one_controller.h"

void printFractionValue(const Fraction &f)
{
    if(f.denominator == 0)
    {
        // 长字符串必须用 "" ， ''只能给char
        cout << string_view{"denominator can not be zero!!!"}<< endl;
    }else{
        cout<< f.numerator / f.denominator<< '\n';
    }
}

void printDate(const Date& date)
{
    cout<< date.m_day << '/' << date.m_month << '/' << date.m_year << endl;
}

constexpr string_view animalName(AnimalType type){
    switch (type)
    {
    case cat/* constant-expression */:
        /* code */
        return "cat";
    case dog:
        return "dog";
    case chicken:
        return "chicken";
    default:
        return "";
    }
}

constexpr int numLegs(AnimalType type){
    switch (type)
    {
    case cat/* constant-expression */:
        /* code */
        return 4;
    case dog:
        return 4;
    case chicken:
        return 2;
    default:
        return 0;
    }
}


void Employee::whoAmI()
{
    Fraction f{5, 0};
    printFractionValue(f);
    cout<< "I am class : one_controller" <<endl;
    Date date{4, 10, 21};
    printDate(date);

    f.print();// struct member function

    constexpr AnimalType animal{cat};
    cout << "A " << animalName(animal) << " has " << numLegs(animal) << endl;
}
